package com.regexs;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @className: Test3
 * @description: TODO 类描述
 * @author: YUANG
 * @date: 2021/12/29
 **/
public class Test3 {
    public static void main(String[] args) {
        String regex1 = "(\\d{3,4})\\-(\\d{6,8})";
        Pattern p1 = Pattern.compile(regex1);
        Matcher m1 = p1.matcher("010-12345678");
        if (m1.matches()) {
            String g1 = m1.group(1);
            String g2 = m1.group(2);
            System.out.println(g1);
            System.out.println(g2);
        } else {
            System.out.println("失败");
        }
    }
}
